﻿using System;

namespace Program14
{
    //定义枚举
   public enum Gender
    {
        男,
        女,
        其他   
    }
    public enum QQstate
    {
        onlin=1,
        offine=0,
        leave=2,
        busy=3,
        Qme=4
    }
    class Program
    {
        static void Main(string[] args)
        {
            //Console.WriteLine(Gender.男);
            //Console.WriteLine(Gender.女);
            //Console.WriteLine(Gender.男.ToString());

            //QQstate state = QQstate.onlin;
            //int n = (int)state;
            //Console.WriteLine("QQ在线枚举成员的值：" + n);

            //Console.WriteLine("QQ离线枚举成员的值：" + (int)QQstate.offine);
            //Console.WriteLine("QQ离开枚举成员的值：" + (int)QQstate.leave);
            //Console.WriteLine("QQ忙碌枚举成员的值：" + (int)QQstate.busy);
            //Console.WriteLine("QQ无聊枚举成员的值：" + (int)QQstate.Qme);



            int n1 = 5;
            int n2 = 4;
            var state1 = (QQstate)n1;
            var state2 = (QQstate)n2;
            Console.WriteLine("QQ状态：" + state1);
            Console.WriteLine("QQ状态：" + state2);

            //将字符串类型转换为枚举类型
            string s = "其他";
            //将"其他"转换成Gender.其他
            //字符串类型转换为枚举型语法
            Gender g = (Gender)Enum.Parse(typeof(Gender), s);
            Console.WriteLine(g);
            Console.WriteLine((int)g);
        }
    }
}
